package com.wang.tool.common;

import java.io.Serializable;
import java.util.Objects;

/**
 * 左中右
 *
 * @Author shaopeng
 * @Date 2021/6/19
 */
public class Triplet<L, M, R> implements Serializable {
    private static final long serialVersionUID = 7680574584871995897L;

    private L left;

    private M middle;

    private R right;

    public Triplet() {
    }

    public Triplet(L left, M middle, R right) {
        this.left = left;
        this.right = right;
        this.middle = middle;
    }

    public L getLeft() {
        return left;
    }

    public void setLeft(L left) {
        this.left = left;
    }

    public R getRight() {
        return right;
    }

    public void setRight(R right) {
        this.right = right;
    }

    public M getMiddle() {
        return middle;
    }

    public void setMiddle(M middle) {
        this.middle = middle;
    }

    @Override
    public String toString() {
        return "(" + left + "," + middle + "," + right + ")";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o){
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Triplet<?, ?, ?> triplet = (Triplet<?, ?, ?>) o;
        return Objects.equals(left, triplet.left) &&
                Objects.equals(middle, triplet.middle) &&
                Objects.equals(right, triplet.right);
    }

    @Override
    public int hashCode() {
        return Objects.hash(left, middle, right);
    }
}
